package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallSystem;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallSystemMapper {
    @Delete({
        "delete from haogoumall_system",
        "where system_id = #{systemId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer systemId);

    @Insert({
        "insert into haogoumall_system (system_id, system_key_name, ",
        "system_key_value, system_add_time, ",
        "system_update_time, system_deleted)",
        "values (#{systemId,jdbcType=INTEGER}, #{systemKeyName,jdbcType=VARCHAR}, ",
        "#{systemKeyValue,jdbcType=VARCHAR}, #{systemAddTime,jdbcType=TIMESTAMP}, ",
        "#{systemUpdateTime,jdbcType=TIMESTAMP}, #{systemDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallSystem record);

    @InsertProvider(type=HaogoumallSystemSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallSystem record);

    @Select({
        "select",
        "system_id, system_key_name, system_key_value, system_add_time, system_update_time, ",
        "system_deleted",
        "from haogoumall_system",
        "where system_id = #{systemId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="system_id", property="systemId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="system_key_name", property="systemKeyName", jdbcType=JdbcType.VARCHAR),
        @Result(column="system_key_value", property="systemKeyValue", jdbcType=JdbcType.VARCHAR),
        @Result(column="system_add_time", property="systemAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="system_update_time", property="systemUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="system_deleted", property="systemDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallSystem selectByPrimaryKey(Integer systemId);

    @UpdateProvider(type=HaogoumallSystemSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallSystem record);

    @Update({
        "update haogoumall_system",
        "set system_key_name = #{systemKeyName,jdbcType=VARCHAR},",
          "system_key_value = #{systemKeyValue,jdbcType=VARCHAR},",
          "system_add_time = #{systemAddTime,jdbcType=TIMESTAMP},",
          "system_update_time = #{systemUpdateTime,jdbcType=TIMESTAMP},",
          "system_deleted = #{systemDeleted,jdbcType=BIT}",
        "where system_id = #{systemId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallSystem record);
}